package ${package.Controller};

import org.springframework.web.bind.annotation.*;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import io.swagger.annotations.*;
import java.util.*;
import com.zcb.scb.common.dto.PageParam;
import com.zcb.scb.common.dto.PageResult;
import com.zcb.scb.common.dto.Result;
import  ${package.Service}.${table.serviceImplName};
import  ${package.Entity}.${table.entityName};
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

import java.util.List;

/**
 * <p>
 * ${table.comment!} 控制器
 * </p>
 *
 * @author ${author}
 * @date ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@CrossOrigin
@Api(value = "${table.comment!}接口", tags = {"${table.comment!}接口API"})
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

    @Resource
    private ${table.serviceImplName} ${table.entityPath}Service;

    @ApiOperation("${table.comment}详情查询")
    @GetMapping("/get${entity}ById")
    public Result<${entity}> get${entity}ById(@RequestParam("id") Integer id) {
        return ${table.entityPath}Service.get${entity}ById(id);
    }

    @ApiOperation("${table.comment}列表查询")
    @PostMapping("list${entity}")
    public Result<List<${entity}>> list${entity}(@ApiParam("查询对象") @RequestBody ${entity} dto) {
        return ${table.entityPath}Service.list${entity}(dto);
    }

    @ApiOperation("${table.comment}分页列表查询")
    @PostMapping("/pageList${entity}")
    public Result<PageResult<${entity}>> pageList${entity}(@ApiParam("分页查询对象") @RequestBody PageParam<${entity}> dto) {
        return ${table.entityPath}Service.pageList${entity}(dto);
    }

    @ApiOperation("${table.comment}新增")
    @PostMapping("/add${entity}")
    public Result<Integer> add${entity}(@ApiParam("新增${table.comment}对象") @RequestBody ${entity} dto) {
        return ${table.entityPath}Service.add${entity}(dto);
    }

    @ApiOperation("${table.comment}修改")
    @PostMapping("/upd${entity}")
    public Result<Integer> upd${entity}(@ApiParam("修改${table.comment}对象") @RequestBody ${entity} dto) {
        return ${table.entityPath}Service.upd${entity}(dto);
    }

    @ApiOperation("${table.comment}逻辑删除")
    @PostMapping("/del${entity}")
    public Result<Integer> del${entity}(@ApiParam("删除${table.comment}对象") @RequestBody ${entity} dto) {
        return ${table.entityPath}Service.del${entity}(dto);
    }

    <#--@ApiOperation("物理删除${table.entityPath}",notes="根据id物理删除${table.entityPath}")
    @DeleteMapping("/delete")
    public Result delete(@PathVariable(name = "id") Long id) {
        return ${table.entityPath}Service.delete${entity}ById(id);
    }-->
}
</#if>
